<?php
/**
 * User: YL
 * Date: 2019/6/10
 */

namespace app\common\middleware;

use Closure;
use restful\ResultCode;
use restful\traits\ResultThrow;
use restful\utils\Env;
use think\Request;

class Maintenance
{
    use ResultThrow;

    public function handle(Request $request, Closure $next)
    {
        // 判断是否维护
        if (Env::get('maintenance.status', false)) {
            $this->error('接口维护中...', ResultCode::MAINTENANCE);
        }

        return $next($request);
    }
}